package com.wangqingbo.myspringboot212.entity;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Max;
import java.util.List;

/**
 * 学生的信息类，从配置文件读取数据，并且显示在页面上
 * 注解@ConfigurationProperties(prefix = "student")：从配置文件中取数据
 * 把取到的值自动赋值到类的属性上
 * 规则：类中属性的名称和配置文件中key的值一致
 * prefix：配置文件中key的父节点
 * 注解@Validated：数据验证
 */
//@Configuration
@Component
@ConfigurationProperties(prefix = "student")
@Validated
public class StudentInfo {
    // 名称
    private String username;
    // 密码
    private String password;
    // 成绩
    @Max(value = 100)
    private int score;
    // 去过的城市
    private List<String> cityes;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public List<String> getCityes() {
        return cityes;
    }

    public void setCityes(List<String> cityes) {
        this.cityes = cityes;
    }
}
